package xiaomin.demo.algorithm;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Lesson11 {
    public static void run(){
        int min=1,max=9;
        int[] a={1,3,6,2,2,9};

        Map<Integer,Integer> dic =new HashMap<Integer,Integer>();

        for(int x:a){
            if(!dic.containsKey(x)){
                dic.put(x,x);
            }
        }


        Random random= new Random();
        int range=max-min+1;
        int res=-1;
        do {
            res =random.nextInt(range)+min;
        }while (dic.containsKey(res));

        System.out.println(res);
    }
}
